<#include "../../common/header.htm">
<div class="content-wrapper">
	<section class="content" id="plan">
		<div class="base_dict_search">
			<span>关键字</span>
			<input  type="text" v-model="keyword" placeholder=" 机场名称/机场所在地">
			<button @click="onSubmit">查询</button>
			<button onclick="openPlanDialog('新增机场信息',null)">新增</button>
		</div>
		<div class="dg">
			<table id="dg"></table>
		</div>
	</section>
</div>
<script>
	var vm=new Vue({
		el:"#plan",
		data:{
			keyword:""
		},
		methods:{
			onSubmit(){
				dg()
			},
		}
	})
	dg()
	function openPlanDialog(title,id) {
		var param={
			id:id
		}
		var d = top.dialog({
			title : title,
			modal : true,
			url : '${ctx}/plane/openPlaneDialog',
			height : 620,
			data : param,
			width : 800
		});
		d.addEventListener('close', function () {
			dg();
		});
		d.show();
	}
	function dg(){
		$('#dg').datagrid({
			url: '${ctx}/plane/page',
			method: 'post',
			iconCls: 'icon-save',
			queryParams:{//每次请求的参数
				keyword:vm.keyword
			},
			pageSize:30,
			pageList:[30,50,100,150,200],
			pageNumber:1,//当前页号,
			//sortName:"TOTALMONEY",//排序列名称 设置后将向后台传送名为sort的post/get参数
			//sortOrder:"desc",//排序列升降序 设置后将向后台传送名为order的post/get参数
			loadMsg:"正在加载，请稍后",//加载数据时的提示信息
			emptyMsg:"暂无信息",//加载数据为空时的信息
			height: ($(window).height())-($('.base_dict_search').outerHeight(true))-50,
			rownumbers:true,//序号
			fitColumns: true,//使表格自适应页面宽度
			pagination: true,//是否分页
			singleSelect: true,
			columns:[[ //每一列的具体设置。
				{field:'planeName',title:'机场名称'},
				{field:'planeAlias',title:'机场别名'},
				{field:'location',title:'所在地'},
				{field:'planeAddress',title:'机场地址'},
				{field:'jd',title:'经度'},
				{field:'wd',title:'维度'},
				{field:'operate',title:'操作',
					formatter: function(value,row,index){
						let id=row.id;
						let s="<a href='#' onclick='edit("+id+")'>修改</a>&nbsp;&nbsp;<a href='#' onclick='del("+id+")'>删除</a>"
						return s
					}
				},
			]],
			onHeaderContextMenu: function(e, field){
				e.preventDefault();
				if (!cmenu){
					createColumnMenu();
				}
				cmenu.menu('show', {
					left:e.pageX,
					top:e.pageY
				});
			},
			onLoadSuccess: function(){
				// refreshSize();
			}
		});
	}
	function edit(id) {
		openPlanDialog("编辑机场信息",id)
	}
	function del(id) {
		var d = dialog({
			title: '提示',
			content: '您确定要删除么！',
			okValue: '确 定',
			ok: function() {
				$.ajax({
					url:"${ctx}/plane/del",
					type: "post",
					data: {
						id:id,
					},
					dataType: "json",
					success: function (msg) {
						if (msg.flag) {
							vm.$message('删除成功');
							dg()
						}
					},

				})
				return true;
			},
			cancelValue: '取消',
			cancel: function() {
			}
		}).show()
	}

</script>
<style>
	.base_dict_search{
		padding: 20px;
	}
	.dg{
		margin-left: 20px;
	}
</style>